﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
using TextEditor.TextBoxInner.DrawingElements;

namespace TextEditor.TextBoxInner.Layers
{
	internal class CollapseLayer : LayerBase<TextLine>
	{
		private static readonly TextLineCreator _textLineCreator = new TextLineCreator();
		private readonly VerticalLine _verticalLine = new VerticalLine();

		public CollapseLayer() : base(_textLineCreator)
		{ }

		protected override int VisualChildrenCount
		{
			get
			{
				return base.VisualChildrenCount + 1;
			}
		}

		protected override Visual GetVisualChild(int index)
		{
			if (index == VisualChildrenCount - 1)
				return _verticalLine;

			return base.GetVisualChild(index);
		}

		private class TextLineCreator : DrawingElementFactory<TextLine>
		{
			internal override TextLine Create()
			{
				return new TextLine();
			}
		}
	}
}
